<?php

class Passport_LoginController extends Base_Controller_Action
{
    
    public function indexAction()
    {
        #print_r($GLOBALS['_COOKIE']);exit;
        if (Base_Auth::isLogin()) {
            $this->_helper->LoginJump();
        }
        
        $form = new Form_Login_Index();
        if ($this->_request->isPost()) {
            if ($form->isValid($this->_request->getPost())) {
                //authenticate login
                if (Base_Auth::authenticate(
                    $form->getValue('username'), $form->getValue('password'))) {
                    $this->_helper->LoginJump();
                }
                $form->password->addError('Auth faild');
            }
        }

        $this->view->form = $form;
        $this->_helper->layout->setLayout('browse');
    }
    
    public function logoutAction()
    {
        Base_Auth::clearIdentity();
        return $this->_helper->LoginJump();
    }
}